% 引入符号工具箱
syms y_n1 y_n2 x_u y_u x_w y_w m1 m2 theta_w lambda d 

% 定义表达式
f = cos(-2*pi/lambda * (sqrt(x_u^2 + (y_u - y_n1)^2) - sqrt(x_w^2 + (y_w - y_n1)^2)) ...
    + 2*pi/lambda * (sqrt(x_u^2 + (y_u - y_n2)^2) - sqrt(x_w^2 + (y_w - y_n2)^2)) ...
    + 2*pi/lambda * (m1 - m2) * d * (sin(theta_w) - sin(theta_w)));

% 对 y_n1 求导
df_dy_n1 = diff(f, y_n1);

% 显示结果
disp(df_dy_n1);

% -(2*pi*sin((2*pi*(((y_n1 - y_u)^2 + x_u^2)^(1/2) - ((y_n1 - y_w)^2 + x_w^2)^(1/2)))/lambda - (2*pi*(((y_n2 - y_u)^2 + x_u^2)^(1/2) - ...
%　    ((y_n2 - y_w)^2 + x_w^2)^(1/2)))/lambda)*((2*y_n1 - 2*y_u)/(2*((y_n1 - y_u)^2 + x_u^2)^(1/2)) - ...
%    (2*y_n1 - 2*y_w)/(2*((y_n1 - y_w)^2 + x_w^2)^(1/2))))/lambda


x = 0:0.1:40;
% plot(sqrt(x.^2+100));
plot(cos(sqrt(x.^2+1)));